<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式系统服务调用架构对比</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* 首字下沉效果 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #4f46e5;
        }
        
        /* 卡片悬停效果 */
        .feature-card {
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
            background: rgba(255, 255, 255, 0.9);
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            background: rgba(255, 255, 255, 0.95);
        }
        
        /* 标题装饰线 */
        .section-title::after {
            content: '';
            display: block;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 100%);
            margin-top: 1rem;
            border-radius: 2px;
        }
        
        /* 列表项动画 */
        .list-item {
            position: relative;
            padding-left: 2rem;
        }
        
        .list-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0.5rem;
            width: 8px;
            height: 8px;
            background: #4f46e5;
            border-radius: 50%;
            transition: all 0.3s ease;
        }
        
        .list-item:hover::before {
            transform: scale(1.5);
            background: #7c3aed;
        }
        
        /* 比较表格样式 */
        .comparison-table {
            backdrop-filter: blur(10px);
            background: rgba(255, 255, 255, 0.9);
        }
        
        /* 图表容器样式 */
        .mermaid-container {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 1rem;
            padding: 2rem;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        /* 滚动动画 */
        .fade-in {
            opacity: 0;
            transform: translateY(20px);
            animation: fadeIn 0.8s ease forwards;
        }
        
        @keyframes fadeIn {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* 延迟动画 */
        .delay-1 { animation-delay: 0.1s; }
        .delay-2 { animation-delay: 0.2s; }
        .delay-3 { animation-delay: 0.3s; }
        .delay-4 { animation-delay: 0.4s; }
    </style>
</head>
<body>
    <!-- Hero 区域 -->
    <section class="relative overflow-hidden">
        <div class="absolute inset-0 bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-500 opacity-90"></div>
        <div class="relative z-10 container mx-auto px-6 py-24 text-center text-white">
            <h1 class="text-5xl md:text-7xl font-bold mb-6 fade-in">
                分布式系统服务调用架构
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90 fade-in delay-1">
                注册中心 vs 直连：深度对比与最佳实践
            </p>
            <div class="flex justify-center space-x-4 fade-in delay-2">
                <span class="inline-flex items-center px-4 py-2 bg-white bg-opacity-20 rounded-full">
                    <i class="fas fa-network-wired mr-2"></i>
                    微服务架构
                </span>
                <span class="inline-flex items-center px-4 py-2 bg-white bg-opacity-20 rounded-full">
                    <i class="fas fa-server mr-2"></i>
                    服务治理
                </span>
                <span class="inline-flex items-center px-4 py-2 bg-white bg-opacity-20 rounded-full">
                    <i class="fas fa-chart-line mr-2"></i>
                    高可用设计
                </span>
            </div>
        </div>
    </section>

    <!-- 引言部分 -->
    <section class="container mx-auto px-6 py-16">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12 fade-in delay-3">
                <p class="text-lg leading-relaxed text-gray-700 drop-cap">
                    在分布式系统中，服务之间的调用可以通过<strong class="text-indigo-600">注册中心</strong>或<strong class="text-purple-600">直连</strong>方式来实现。两者在架构、运维、灵活性和可靠性等方面存在显著区别。选择合适的服务调用方式，对系统的性能、可维护性和扩展性都有深远影响。
                </p>
            </div>
        </div>
    </section>

    <!-- 架构对比可视化 -->
    <section class="container mx-auto px-6 py-8">
        <div class="mermaid-container fade-in">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 text-center">架构模式对比</h2>
            <div class="mermaid" id="architecture-diagram">
                graph TB
                    subgraph 注册中心模式
                        RC[注册中心<br/>Service Registry]
                        S1[服务A]
                        S2[服务B]
                        S3[服务C]
                        C1[消费者1]
                        C2[消费者2]
                        
                        S1 -->|注册| RC
                        S2 -->|注册| RC
                        S3 -->|注册| RC
                        C1 -->|发现| RC
                        C2 -->|发现| RC
                        C1 -.->|调用| S1
                        C1 -.->|调用| S2
                        C2 -.->|调用| S2
                        C2 -.->|调用| S3
                    end
                    
                    subgraph 直连模式
                        DS1[服务X]
                        DS2[服务Y]
                        DS3[服务Z]
                        DC1[消费者A]
                        DC2[消费者B]
                        
                        DC1 -->|直接调用| DS1
                        DC1 -->|直接调用| DS2
                        DC2 -->|直接调用| DS2
                        DC2 -->|直接调用| DS3
                    end
                    
                    style RC fill:#4f46e5,stroke:#333,stroke-width:2px,color:#fff
                    style S1 fill:#10b981,stroke:#333,stroke-width:2px,color:#fff
                    style S2 fill:#10b981,stroke:#333,stroke-width:2px,color:#fff
                    style S3 fill:#10b981,stroke:#333,stroke-width:2px,color:#fff
                    style DS1 fill:#f59e0b,stroke:#333,stroke-width:2px,color:#fff
                    style DS2 fill:#f59e0b,stroke:#333,stroke-width:2px,color:#fff
                    style DS3 fill:#f59e0b,stroke:#333,stroke-width:2px,color:#fff
            </div>
        </div>
    </section>

    <!-- 主要内容区域 -->
    <section class="container mx-auto px-6 py-16">
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
            
            <!-- 架构设计对比 -->
            <div class="feature-card rounded-2xl shadow-lg p-8 fade-in">
                <h3 class="text-2xl font-bold text-gray-800 mb-6 section-title">
                    <i class="fas fa-sitemap text-indigo-600 mr-3"></i>架构设计
                </h3>
                
                <div class="space-y-6">
                    <div>
                        <h4 class="text-lg font-semibold text-indigo-600 mb-3">注册中心</h4>
                        <ul class="space-y-3">
                            <li class="list-item text-gray-700">
                                <strong>中心化管理</strong>：集中式服务发现，所有服务统一注册管理
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>动态扩展</strong>：服务实例自动上下线，实时更新服务列表
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>服务治理</strong>：内置负载均衡、熔断、限流等高级功能
                            </li>
                        </ul>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-semibold text-purple-600 mb-3">直连</h4>
                        <ul class="space-y-3">
                            <li class="list-item text-gray-700">
                                <strong>去中心化</strong>：点对点直接通信，无需中间组件
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>静态配置</strong>：服务地址预先配置，适合固定环境
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>简单易用</strong>：架构简洁，降低系统复杂度
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <!-- 灵活性对比 -->
            <div class="feature-card rounded-2xl shadow-lg p-8 fade-in delay-1">
                <h3 class="text-2xl font-bold text-gray-800 mb-6 section-title">
                    <i class="fas fa-sync-alt text-purple-600 mr-3"></i>灵活性
                </h3>
                
                <div class="space-y-6">
                    <div>
                        <h4 class="text-lg font-semibold text-indigo-600 mb-3">注册中心</h4>
                        <ul class="space-y-3">
                            <li class="list-item text-gray-700">
                                <strong>高灵活性</strong>：服务动态上下线，自动感知变化
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>负载均衡</strong>：智能路由，优化资源利用
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>自动故障转移</strong>：故障实例自动剔除，保证高可用
                            </li>
                        </ul>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-semibold text-purple-600 mb-3">直连</h4>
                        <ul class="space-y-3">
                            <li class="list-item text-gray-700">
                                <strong>低灵活性</strong>：地址变更需手动更新配置
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>手动负载均衡</strong>：需要额外实现负载分配逻辑
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>故障处理复杂</strong>：需要自行实现故障检测和切换
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <!-- 性能和可靠性对比 -->
            <div class="feature-card rounded-2xl shadow-lg p-8 fade-in delay-2">
                <h3 class="text-2xl font-bold text-gray-800 mb-6 section-title">
                    <i class="fas fa-tachometer-alt text-green-600 mr-3"></i>性能和可靠性
                </h3>
                
                <div class="space-y-6">
                    <div>
                        <h4 class="text-lg font-semibold text-indigo-600 mb-3">注册中心</h4>
                        <ul class="space-y-3">
                            <li class="list-item text-gray-700">
                                <strong>性能损耗</strong>：服务发现带来额外网络开销
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>单点故障风险</strong>：需要高可用集群部署
                            </li>
                            <li class="list-item text-gray-700">
                                <strong>一致性保证</strong>：分布式环境下的数据同步挑战
                            </li>
                        </ul>
                    </div>
                    
                    <div>
                